function atmosphere(){
	var cameraPos = [0, 1001, 0.0];
	var light = new Float32Array([0, 0.0, 100.0]);
	var params = {
		Kr : 0.0025,
		Km : 0.001,
		g : 0.99,
		ESun : 20,
		innerRadius : 1000,
		outerRadius : 1025,
		waveLength : [0.65, 0.57, 0.475],
		scaleDepth : 0.25
	}
	
	for(var i =0; i < params.waveLength.length; i++){
		params.waveLength[i] = 1/Math.pow(params.waveLength[i], 4)
	}

	var camera = qtre.sceneManager.createCamera("main", {
		eye : [0, 0, 0],
		target : [0, 0, -1],
		up : [0, 1, 0],
		fov : tdl.math.degToRad(45),
		near : 1,
		far : 5000
	})
	var verticalSceneNode = qtre.sceneManager.createSceneNode("main_camera_vertical");
	verticalSceneNode.attachObject(camera);
	verticalSceneNode.translate(cameraPos);
	var horizontalSceneNode = qtre.sceneManager.createSceneNode("main_camera_horizantal");
	horizontalSceneNode.addChild(verticalSceneNode);
	//sky
	var sky = tdl.primitives.createSphere(params.outerRadius+1, 50, 50);
	var renderable = qtre.sceneManager.createRenderable("sky", sky);
	var program = tdl.programs.loadProgramFromScriptTags("skyFromAtmosphereVertex", "skyFromAtmosphereFragment");
	var material = qtre.sceneManager.createMaterial("sky", program);
	var sceneNode = qtre.sceneManager.createSceneNode("sky");
	sceneNode.attachObject(renderable);
	renderable.bindMaterial(material);
	material.bindCamera(camera);
	var lightAngle = 0;
	material.addRenderBeginCallback(function(){
		lightAngle += 0.001;
		var y = -Math.sin(lightAngle);
		var z = Math.cos(lightAngle);
		light[1] =y;
		light[2] = z;
		this.updateUniforms({
			v3LightPos : light
		})
	})
	
	material.updateUniforms({
		v3CameraPos : cameraPos,
		v3LightPos : light,
		v3InvWavelength : params.waveLength,
		fCameraHeight : tdl.math.length(cameraPos),
		fCameraHeight2 : tdl.math.length(cameraPos)*tdl.math.length(cameraPos),
		fOuterRadius : params.outerRadius,
		fOuterRadius2 : params.outerRadius*params.outerRadius,
		fInnerRadius : params.innerRadius,
		fInnerRadius2 : params.innerRadius*params.innerRadius,
		fKrESun : params.Kr * params.ESun,
		fKmESun : params.Km * params.ESun,
		fKr4PI : params.Kr*4*Math.PI,
		fKm4PI : params.Km*4*Math.PI,
		fScale : 1/(params.outerRadius - params.innerRadius),
		fScaleDepth : params.scaleDepth,
		fScaleOverScaleDepth : (1/(params.outerRadius - params.innerRadius))/params.scaleDepth,
		g : params.g,
		g2 : params.g*params.g
	})
	
	//ground
	var ground = tdl.primitives.createSphere(params.innerRadius, 100, 100);
	var renderable = qtre.sceneManager.createRenderable("ground", ground);
	var program = tdl.programs.loadProgramFromScriptTags("groundFromAtmosphereVertex", "groundFromAtmosphereFragment");
	var material = qtre.sceneManager.createMaterial("ground", program);
	material.bindCamera(camera);
	renderable.bindMaterial(material);
	sceneNode.attachObject(renderable);
	material.updateUniforms({
		v3CameraPos : cameraPos,
		v3LightPos : light,
		v3InvWavelength : params.waveLength,
		fCameraHeight : tdl.math.length(cameraPos),
		fCameraHeight2 : tdl.math.length(cameraPos)*tdl.math.length(cameraPos),
		fOuterRadius : params.outerRadius,
		fOuterRadius2 : params.outerRadius*params.outerRadius,
		fInnerRadius : params.innerRadius,
		fInnerRadius2 : params.innerRadius*params.innerRadius,
		fKrESun : params.Kr * params.ESun,
		fKmESun : params.Km * params.ESun,
		fKr4PI : params.Kr*4*Math.PI,
		fKm4PI : params.Km*4*Math.PI,
		fScale : 1/(params.outerRadius - params.innerRadius),
		fScaleDepth : params.scaleDepth,
		fScaleOverScaleDepth : (1/(params.outerRadius - params.innerRadius))/params.scaleDepth,
		g : params.g,
		g2 : params.g*params.g
	})
	
	qtre.input.addEventListener("mousemove", function(){
		if(qtre.input.mouseDown){
			verticalSceneNode.rotateX(Math.PI/600*qtre.input.dy);
			horizontalSceneNode.rotateY(Math.PI/600*qtre.input.dx);
			//sceneNode.rotateY(Math.PI/360*qtre.input.dx);
		}
	})

}